﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Prism.ViewModel;
using Visifire.Gauges;

namespace DIST.LR.ZHJG.Controls.Chart
{
    public partial class ucVFCircularGauge : UserControl
    {
        public ucVFCircularGauge()
        {
            ViewModel vm = new ViewModel(150, 0, 240);
            InitializeComponent();
            this.DataContext = vm;
            this.vfCircularGauge.Loaded += new RoutedEventHandler(vfCircularGauge_Loaded);
        }

        void vfCircularGauge_Loaded(object sender, RoutedEventArgs e)
        {
            var c = sender as Visifire.Gauges.Gauge;
            IEnumerable<TextBlock> labels = VisualTreeAPI.FindVisualChildren<TextBlock>(c.Parent as System.Windows.Controls.Grid);
            foreach (TextBlock txt in labels) 
            {
                if (txt.Text.ToLower().Contains("trial"))
                {
                    txt.Visibility = System.Windows.Visibility.Collapsed;
                    if (txt.Parent is Border)
                    {
                        (txt.Parent as Border).Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    }
                }
            }
        }
    }

    public class ViewModel 
    {
        private double _value;
        private double _minimum;
        private double _maxmum;

        public double Value
        {
            get { return _value; }
            set {  _value = value; }
        }

        public double Minimum
        {
            get { return _minimum; }
            set { _minimum = value; }
        }

        public double Maxmum
        {
            get { return _maxmum; }
            set { _maxmum = value; }
        }

        public ViewModel(double value, double minimum, double maxmum)
        {
            this._value = value;
            this._minimum = minimum;
            this._maxmum = maxmum;
        }

    }
}
